package com.ophiux.member;

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.ophiux.common.feign.annotation.EnableOphiuxFeignClients;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;

/**
 * @desc:
 * @author: hhl
 * @date：2021/10/21 11:43
 */
//@SpringBootApplication
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
@MapperScan("com.ophiux.member.mapper")
@EnableOphiuxFeignClients
public class MemberApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(MemberApplication.class, args);
        Environment evn = context.getBean(Environment.class);
        NacosDiscoveryProperties nacosDiscoveryProperties = context.getBean(NacosDiscoveryProperties.class);
        System.out.println("http://"+nacosDiscoveryProperties.getIp()+":"+nacosDiscoveryProperties.getPort()+"/swagger-ui/index.html");
        System.out.println("会员服务启动成功,端口：" + evn.getProperty("server.port"));
    }

    //loadbalancer默认使用的Ribbon。
    @Bean("restTemplate")
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
    
}
